package sg.edu.nus.iss.vmcs.store;

/*
 * Copyright 2003 ISS.
 * The contents contained in this document may not be reproduced in any
 * form or by any means, without the written permission of ISS, other
 * than for the purpose for which it has been supplied.
 *
 */

/**
 * This entity object implements a generic storage item class. It returns content and quantity, 
 * sets quantity, increment quantity and decrement (release) quantity.
 *
 * @version 3.0 5/07/2003
 * @author Olivo Miotto, Pang Ping Li
 */

public class StoreItem {

	private StoreObject content;
	private int quantity;

	/**
	 * This constructor creates a new instance of the Store Item. It receives the quantity 
	 * of the Store Item and a reference to the Store Object it contains.
	 * @param content from StoreObject
	 * @param quantity of the Store Item
	 */
	public StoreItem(StoreObject content, int quantity) {
		this.content = content;
		this.quantity = quantity;
	}

	/**
	 * This method will return the StoreObject 
	 * that is stored in the StoreItem. 
	 * @return
	 */
	public StoreObject getContent() {
		return content;
	}
	
	/**
	 * This method sets the Store Object held by the Store Item.
	 * @param ct Store Object for this Store Item
	 */
	public void setContent(StoreObject ct) {
		content = ct;
	}

	/**
	 * This method sets the total number of store item held.
	 * @param quantity of the Store Item
	 */
	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	/**
	 * This method gets the total quantity
	 * and return the total number of the store item held.
	 * @return
	 */
	public int getQuantity() {
		return quantity;
	}

	/**
	 * This method will increase the quantity of the Store Item by one.
	 */
	public void store() {
		quantity++;
	}
	
	/**
	 * This method will decrement the item quantity by one. 
	 */
	public void decrement() {
		quantity--;
		if (quantity < 0)
			quantity = 0;
	}

	/**
	 *  This method will increment the item quantity by one. 
	 */
	public void increment() {
		quantity++;
	}
}